Since v5.0 the default visual style of OpenXava is defined in /web/naviox/style/naviox.css. It look like this:
The naviox.css file is in your project but it's copied from the Addons project on deploy. Anyways, instead of modifying naviox.css is better to modify custom.css as explained in the next section.
Modify the default style (new in v4.5)
Since version 4.5 you can add and modify styles with the file custom.css in web/xava/style. To overwrite an existing style just add the style name and define it in your custom.css file. If you put:
You change the font-size to all your application (inside portal too) and the height of the rows in list. Look at naviox.css for a complete list of available CSS classes.
A few css tricks
Here are a couple of css tricks/tips. Please add/edit an entries you feel appropriate. Style @ReadOnly fields uniquely
Add row-xxx to @Tab Sometimes, you will want to extend the existing "row-highlight" styling in the @Tab definition. Here's a way to add, say, "row-red" with hovering as a different color. First, select the row definition you want, and add the following to your custom.css file. You can extend this to font-size, effects, etc. and add any definitions you like.
Remove checkboxes from a specific module
The above changes are global across your application. You can make them specific to a module by including the Application and Module names as part of the string. For example, my Application name is: KitBase and I have a module named Dashboard. Because Dashboard's list is a list of Collections, my entry in custom.css looks like this:
If you want to add your own elements to the page in order they are always present in your application, you can do it in web/naviox/indexExt.jsp of your project. It is included at the end of the page, but using CSS you can place it in any part of the screen.
For example, if you want to show a BETA sign in right top corner, thus:
You can write in your indexExt.jsp:
<divid="beta">BETA</div>
Then place it adding the next code in the custom.css:
Inside portals
Inside a portal OpenXava portlets acquire automatically the portal skin, therefore if you work with a portal just create or modify the style for the portal itself and the OpenXava application will adapt to it. For example, when you deploy your application in Liferay 6 it looks in this way:
Additionally, if you want to specific style for a portal, the next properties are available in xava.properties: liferay6StyleClass, liferay51StyleClass, liferay41StyleClass, liferay43StyleClass, webSpherePortal61StyleClass, webSpherePortal6StyleClass, webSpherePortalStyleClass, JetSpeed2Style.
Thus, if you want create your own style for OpenXava applications running inside a Liferay 6, just add the next line to xava.properties:
Of course, you have to write the MyLiferayStyle class.
Defining your own style (until v4.9.1)
These instructions are for v4.2 to v4.9.1, for older versions consult OpenXavaTest/xava.properties. For v5.0 or better use default.css as explained above.
For defining your own style add the next entries to the xava.properties files of your project:
Then create a folder called mystyle inside web/xava/style, and add a file mystyle.css in that folder. In this file you can use the next CSS classes: ox-module, ox-view, ox-detail, ox-action-link, ox-image-link, ox-button-bar, ox-button-bar-button, ox-active, ox-first, ox-last, ox-label, ox-module-description, ox-frame-content, ox-list, ox-list-header, ox-list-subheader, ox-list-pair, ox-list-odd, list-pair-selected, list-odd-selected, ox-list-info, ox-list-info-detail, ox-list-title, ox-header-list-count, ox-frame (new in v4.8, before it was frame), ox-frame-actions, ox-frame-title, ox-frame-title-label, ox-errors, ox-messages, ox-section, ox-section-tab, ox-active-section, ox-section-link, ox-collection-list-actions, ox-bottom-buttons, ox-page-navigation-selected, ox-page-navigation, ox-page-navigation-pages, ox-page-navigation-arrow, ox-page-navigation-arrow-disable, ox-images-gallery (new in v4.8), ox-help, ox-total-row, ox-total-cell, ox-total-capable-cell, ox-filter-cell, ox-frame-totals, ox-frame-totals-label, ox-frame-totals-value.
Optionally, you can create your own Style class extending org.openxava.web.style.Style. This allows you even more control over look & feel, layout and behavior of your application.
Predefined styles (until v4.9.1)
You can use the styles in this section with v5.0 if you deactivate menus and login as explained in migration from v4.9.1 to v5.0.
OpenXava comes with some predefined styles. You can configure them in properties/xava.properties of your project:
# styleClass and styleCSS have only effect outside a portal,
# inside a portal OX portlets acquire automatically the portal skin.
# Liferay 5.1: This is the DEFAULT, so you do not need to uncomment the next lines
#styleClass=org.openxava.web.style.Liferay51Style
#styleCSS=liferay51/css/everything_unpacked.css
# Liferay 4.3/4.4/5.0: uncomment the next line for use this nice and slow style
#styleClass=org.openxava.web.style.Liferay43Style
#styleCSS=liferay43/css/everything_unpacked.css
# Classic style: uncomment the next line for use the old OX style
#styleClass=org.openxava.web.style.PortalStyle
#styleCSS=default.css
An example: iPad style (until v4.9.1)
With v5.0 the standard style works fine with tablets, anyways you can use the old iPad style with v5.0 if you deactivate menus and login as explained in migration from v4.9.1 to v5.0. Moreover, since v5.1 you should add the entry org.openxava.web.style.IPadStyle in styles.properties.
iPad style is included by default in OpenXava and it is activated automatically when the user access to the application from an iPad.
Browser/device detection
In order to achieve the device detection, we add the next method in the style class:
This is the way to match a specific style for a specific browser or device. You can use this technique in your style, though if you do so, you have to create a styles.properties file in the properties folder of your project, adding a line with the class of your style, as the next one:
com.mycompany.myapp.style.MyDeviceStyle
Moreover, you have to write MyDeviceStyle class with the appropriate isForBrowse() method.
JavaScript code
iPad style also uses native iPad effects like flip and slide. To achieve it we use some JavaScript code. In this case we define a custom method to specify the way a HTML token retrieved from server with AJAX is assigned to a HTML document element:
public String getSetHtmlFunction() {
return "ipad.setHtml";
}
In this way, we indicate that the function to be used is ipad.setHtml, instead of the standard one. This function is defined in an ipad.js file. We must indicate to the style class that loads this JavaScript file:
Table of Contents
Custom visual style
Since v5.0 the default visual style of OpenXava is defined in /web/naviox/style/naviox.css. It look like this:The naviox.css file is in your project but it's copied from the Addons project on deploy. Anyways, instead of modifying naviox.css is better to modify custom.css as explained in the next section.
Modify the default style (new in v4.5)
Since version 4.5 you can add and modify styles with the file custom.css in web/xava/style.To overwrite an existing style just add the style name and define it in your custom.css file. If you put:
body{ font-size: 9px; } .ox-list-pair, .ox-list-odd { height: 20px; }You change the font-size to all your application (inside portal too) and the height of the rows in list. Look at naviox.css for a complete list of available CSS classes.A few css tricks
Here are a couple of css tricks/tips. Please add/edit an entries you feel appropriate.Style @ReadOnly fields uniquely
input[disabled] { background: black; color: white; ... }Add row-xxx to @TabSometimes, you will want to extend the existing "row-highlight" styling in the @Tab definition. Here's a way to add, say, "row-red" with hovering as a different color.
First, select the row definition you want, and add the following to your custom.css file. You can extend this to font-size, effects, etc. and add any definitions you like.
tr.row-red { background: red; } tr .row-red:hover { background: yellow; }Remove the Application and Module display between Main Menu and body (frees screen real estate)#module_description { display: none; }Remove checkboxes from list-mode display.ox-list-header input[type="checkbox"] { display: none; }.ox-list-pair input[type="checkbox"] { display: none; }.ox-list-odd input[type="checkbox"] { display: none; }Remove checkboxes from a specific moduleThe above changes are global across your application. You can make them specific to a module by including the Application and Module names as part of the string. For example, my Application name is: KitBase and I have a module named Dashboard. Because Dashboard's list is a list of Collections, my entry in custom.css looks like this:
.ox_KitBase_Dashboard__collection_scroll input[type="checkbox"] { display: none; }If it were a standard list of properties, the entry would look like this:.ox_KitBase_Dashboard__list_scroll input[type="checkbox"] { display: none; }*Note the double underscore between the module name and the rest of the string! *Change background color of list-mode hover
.ox-list-pair:hover, .ox-list-odd:hover { background: #9EA8AD; }Add elements to the page (new in v5.6)
If you want to add your own elements to the page in order they are always present in your application, you can do it in web/naviox/indexExt.jsp of your project. It is included at the end of the page, but using CSS you can place it in any part of the screen.For example, if you want to show a BETA sign in right top corner, thus:
You can write in your indexExt.jsp:
Then place it adding the next code in the custom.css:
Inside portals
Inside a portal OpenXava portlets acquire automatically the portal skin, therefore if you work with a portal just create or modify the style for the portal itself and the OpenXava application will adapt to it. For example, when you deploy your application in Liferay 6 it looks in this way:
Additionally, if you want to specific style for a portal, the next properties are available in xava.properties: liferay6StyleClass, liferay51StyleClass, liferay41StyleClass, liferay43StyleClass, webSpherePortal61StyleClass, webSpherePortal6StyleClass, webSpherePortalStyleClass, JetSpeed2Style.
Thus, if you want create your own style for OpenXava applications running inside a Liferay 6, just add the next line to xava.properties:
Of course, you have to write the MyLiferayStyle class.
Defining your own style (until v4.9.1)
These instructions are for v4.2 to v4.9.1, for older versions consult OpenXavaTest/xava.properties. For v5.0 or better use default.css as explained above.For defining your own style add the next entries to the xava.properties files of your project:
Then create a folder called mystyle inside web/xava/style, and add a file mystyle.css in that folder. In this file you can use the next CSS classes: ox-module, ox-view, ox-detail, ox-action-link, ox-image-link, ox-button-bar, ox-button-bar-button, ox-active, ox-first, ox-last, ox-label, ox-module-description, ox-frame-content, ox-list, ox-list-header, ox-list-subheader, ox-list-pair, ox-list-odd, list-pair-selected, list-odd-selected, ox-list-info, ox-list-info-detail, ox-list-title, ox-header-list-count, ox-frame (new in v4.8, before it was frame), ox-frame-actions, ox-frame-title, ox-frame-title-label, ox-errors, ox-messages, ox-section, ox-section-tab, ox-active-section, ox-section-link, ox-collection-list-actions, ox-bottom-buttons, ox-page-navigation-selected, ox-page-navigation, ox-page-navigation-pages, ox-page-navigation-arrow, ox-page-navigation-arrow-disable, ox-images-gallery (new in v4.8), ox-help, ox-total-row, ox-total-cell, ox-total-capable-cell, ox-filter-cell, ox-frame-totals, ox-frame-totals-label, ox-frame-totals-value.
Optionally, you can create your own Style class extending org.openxava.web.style.Style. This allows you even more control over look & feel, layout and behavior of your application.
Predefined styles (until v4.9.1)
You can use the styles in this section with v5.0 if you deactivate menus and login as explained in migration from v4.9.1 to v5.0.OpenXava comes with some predefined styles. You can configure them in properties/xava.properties of your project:
An example: iPad style (until v4.9.1)
With v5.0 the standard style works fine with tablets, anyways you can use the old iPad style with v5.0 if you deactivate menus and login as explained in migration from v4.9.1 to v5.0. Moreover, since v5.1 you should add the entry org.openxava.web.style.IPadStyle in styles.properties.iPad style is included by default in OpenXava and it is activated automatically when the user access to the application from an iPad.
Browser/device detection
In order to achieve the device detection, we add the next method in the style class:public boolean isForBrowse(String browser) { return browser != null && browser.contains("iPad"); }This is the way to match a specific style for a specific browser or device. You can use this technique in your style, though if you do so, you have to create a styles.properties file in the properties folder of your project, adding a line with the class of your style, as the next one:Moreover, you have to write MyDeviceStyle class with the appropriate isForBrowse() method.
JavaScript code
iPad style also uses native iPad effects like flip and slide. To achieve it we use some JavaScript code. In this case we define a custom method to specify the way a HTML token retrieved from server with AJAX is assigned to a HTML document element:public String getSetHtmlFunction() { return "ipad.setHtml"; }In this way, we indicate that the function to be used is ipad.setHtml, instead of the standard one. This function is defined in an ipad.js file. We must indicate to the style class that loads this JavaScript file:private static String [] jsFiles = { "ipad/ipad.js", }; public String [] getNoPortalModuleJsFiles() { return jsFiles; }This ipad.js file is on the web/style/ipad folder:CSS file
Here the complete ipad.css file. You can find this file in the OpenXava distribution, in OpenXava/web/style/ipad folder.Style class
Here the complete code for the IPadStyle class. You can find this class in the OpenXava distribution, in OpenXava/src/org.openxava.web.style.pair:hover, .ox-list-odd:hover {